package com.wxp.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.validator.constraints.Length;

@Entity
@Table(name = "t_resource")
public class Resource {
	
	public Resource(){}
	
	public Resource(String operator,String module,String permission,String aurl,String operatorName,String operatorType,String parentOperator){
		this.operator = operator;
		this.module = module;
		this.permission = permission;
		this.aurl=aurl;
		this.operatorName = operatorName;
		this.operatorType = operatorType;
		this.parentOperator = parentOperator;
	}
	
	



	@Id
	@Length(max=64)
	@Column(name="OPERATOR_" ,nullable = false ,unique = true ,insertable = true ,updatable = true,length=64)
	private String operator;
	
	@Length(max=64)
	@Column(name="MODULE_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=64)
	private String module;
	
	@Length(max=512)
	@Column(name="PERMISSION_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=512)
	private String permission;
	
	@Length(max=64)
	@Column(name="URL_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=64)
	private String aurl;
	
	@Length(max=64)
	@Column(name="OPERATOR_NAME_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=64)
	private String operatorName;
	
	@Length(max=64)
	@Column(name="OPERATOR_TYPE_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=64)
	private String operatorType;
	
	
	@Length(max=64)
	@Column(name="PARENT_OPERATOR_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=64)
	private String parentOperator;
	
	@Length(max=64)
	@Column(name="CHECKED_" ,nullable = true ,unique = false ,insertable = true ,updatable = true,length=64)
	private String checked;



	public String getOperator() {
		return operator;
	}



	public void setOperator(String operator) {
		this.operator = operator;
	}



	public String getModule() {
		return module;
	}



	public void setModule(String module) {
		this.module = module;
	}



	public String getPermission() {
		return permission;
	}



	public void setPermission(String permission) {
		this.permission = permission;
	}



	



	public String getAurl() {
		return aurl;
	}

	public void setAurl(String aurl) {
		this.aurl = aurl;
	}

	public String getOperatorName() {
		return operatorName;
	}



	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}


	public String getOperatorType() {
		return operatorType;
	}

	public void setOperatorType(String operatorType) {
		this.operatorType = operatorType;
	}

	
	
	

	
	public String getChecked() {
		return checked;
	}

	public void setChecked(String checked) {
		this.checked = checked;
	}

	@Override
	public String toString() {
		return "Resource [operator=" + operator + ", module=" + module + ", permission=" + permission + ", aurl=" + aurl
				+ ", operatorName=" + operatorName + ", operatorType=" + operatorType + ", parentOperator="
				+ parentOperator + "]";
	}

	public String getParentOperator() {
		return parentOperator;
	}

	
	public void setParentOperator(String parentOperator) {
		this.parentOperator = parentOperator;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getOperator())
			.toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Resource == false) return false;
		if(this == obj) return true;
		Resource other = (Resource)obj;
		return new EqualsBuilder()
			.append(getOperator(),other.getOperator())
			.isEquals();
	}
}
